clear all;
clc;

load mnist_all

c = 3;
n = zeros(10,1);
for i = 1:10
    n(i) = size(eval(strcat('test',int2str(i-1))),1);
end
m = cumsum(n);
label = -ones(n(1)+n(2)+n(3),3);
label(1:m(1),1) = ones(n(1),1);
for i = 2:c
    label(m(i-1)+1:m(i),i) = ones(n(i),1);
end

idx = randperm(size(label,1));
label = int8(label(idx,:));
data = [test0;test1;test2];
data = data(idx,:);

save('mnist0v1v2','data','label');